var parseString = require('xml2js').parseString;

var XmlToJsonHelper = {

	xmlToJson: function(xml, fnCb){
		parseString(xml, { explicitArray : false, ignoreAttrs : true }, function(err, result){
			if(!err){
				var json_result = JSON.parse(JSON.stringify(result));
            	fnCb(err, json_result);
			}else{
				fnCb(err, null);	
			}
        });	
	}
	
}

module.exports = XmlToJsonHelper;